import React from "react";

const ProtoContext = React.createContext(null);

function ProtoProvider(props) {
	const [protoClasses, setProtoClasses] = React.useState([]);
	const [protos, setProtos] = React.useState([]);
	const [proto, setProto] = React.useState({});
	const [activeClassId, setActiveClassId] = React.useState(null);
	const [activeProtoId, setActiveProtoId] = React.useState(null);
	return (
		<ProtoContext.Provider
			value={{
				proto,
				setProto,
				protos,
				setProtos,
				protoClasses,
				setProtoClasses,
				activeClassId,
				setActiveClassId,
				activeProtoId,
				setActiveProtoId,
			}}
		>
			{props.children}
		</ProtoContext.Provider>
	);
}

function useProtoContext() {
	return React.useContext(ProtoContext);
}

export { ProtoContext, ProtoProvider, useProtoContext };
